home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 127 / PC Guia 127.iso / Software / Produtividade / OpenOffice.org 2.0.1 / openofficeorg4.cab / Iterators.py < prev    next >
Text File  |  2005-11-19  |  686b  |  26 lines

  1. # Copyright (C) 2001,2002 Python Software Foundation
  2. # Author: barry@zope.com (Barry Warsaw)
  3.  
  4. """Various types of useful iterators and generators.
  5. """
  6.  
  7. import sys
  8.  
  9. try:
  10.     from email._compat22 import body_line_iterator, typed_subpart_iterator
  11. except SyntaxError:
  12.     # Python 2.1 doesn't have generators
  13.     from email._compat21 import body_line_iterator, typed_subpart_iterator
  14.  
  15.  
  16.  
  17. def _structure(msg, fp=None, level=0):
  18.     """A handy debugging aid"""
  19.     if fp is None:
  20.         fp = sys.stdout
  21.     tab = ' ' * (level * 4)
  22.     print >> fp, tab + msg.get_content_type()
  23.     if msg.is_multipart():
  24.         for subpart in msg.get_payload():
  25.             _structure(subpart, fp, level+1)
  26.